																																																																																														package com.chinasoft.entity;

public class Page {
	private int totalpage;
	private int totalmessage;
	private int currentpage;
	private int beginindex;
	private int endindex;
	private int pagesize=5;
	public Page(int totalmessage,int currentpage){
		this.totalmessage=totalmessage;
		this.currentpage=currentpage;
		calulate();
		
	}
	public void calulate(){
		totalpage = totalmessage/pagesize+((totalmessage%pagesize)==0?0:1);
		if(currentpage>totalpage){
			currentpage = totalpage;
		}else if(currentpage<1){
			currentpage=1;
		}
		beginindex = (currentpage-1)*pagesize;
		endindex = beginindex+pagesize;
	}
	public int getTotalpage() {
		return totalpage;
	}
	public void setTotalpage(int totalpage) {
		this.totalpage = totalpage;
	}
	public int getTotalmessage() {
		return totalmessage;
	}
	public void setTotalmessage(int totalmessage) {
		this.totalmessage = totalmessage;
	}
	public int getCurrentpage() {
		return currentpage;
	}
	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}
	public int getBeginindex() {
		return beginindex;
	}
	public void setBeginindex(int beginindex) {
		this.beginindex = beginindex;
	}
	public int getEndindex() {
		return endindex;
	}
	public void setEndindex(int endindex) {
		this.endindex = endindex;
	}
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	
}
